// 这里路径中使用了@是我们配置的别名
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
//配置路由
const routes: Array<RouteRecordRaw> = [{
    path:'/',
    name:'Home',
    //在router/index.ts中，当URL为/时，会渲染组件views/home/index.vue，因为在App.vue中已经配置了<router-view></router-view>，且在main.ts中已经使用了createApp(App).use(router)
    component:()=>import('@/views/home/index.vue'),
    meta:{},
    children:[],
}];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

//路由拦截
router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});
//路由后置钩子
router.afterEach((_to) => {
  NProgress.done();
});

export default router 

// 这里的NProgress.start()和nProgress.done()是用来控制进度条的，
// 具体用法可以参考nprogress的文档 https://www.npmjs.com/package/nprogress       